﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AnesSystem.Util.Date
{
    /// <summary>
    /// TimePickerCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class TimePickerCtrl : UserControl
    {
        public TimePickerCtrl()
        {
            InitializeComponent();
        }


        private void Loaded_Text(DateTime dateTime)
        {
            //显示界面
           // _textBlock.Text = dateTime.ToString();
             DateTime = dateTime;
        }



        public string ContentValue
        {
            get { return (string)GetValue(ContentValueProperty); }
            set { SetValue(ContentValueProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ContentValue.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ContentValueProperty =
            DependencyProperty.Register("ContentValue", typeof(string), typeof(TimePickerCtrl), new PropertyMetadata("点击"));



        public DateTime SelDateTime
        {
            get { return (DateTime)GetValue(SelDateTimeProperty); }
            set { SetValue(SelDateTimeProperty, value); }
        }

        // Using a DependencyProperty as the backing store for SelDateTime.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty SelDateTimeProperty =
            DependencyProperty.Register("SelDateTime", typeof(DateTime), typeof(TimePickerCtrl), new PropertyMetadata(DateTime.Now));


        public DateTime DateTime { get { return SelDateTime; } set { SelDateTime = value; } }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

            TimePicker dtView = new TimePicker(_textBlock.Text);// TDateTimeView  构造函数传入日期时间
            dtView.Show();
            dtView.DateTimeOK += (dateTimeStr) => //TDateTimeView 日期时间确定事件
            {
                DateTime t = Convert.ToDateTime(dateTimeStr);
                Loaded_Text(t);
               
            };
           
        }
    }
}
